﻿using Abp.Application.Services.Dto;
using Abp.Domain.Repositories;
using Batman.Cms.Controllers.Inputs;
using Batman.Cms.Core.Services;
using Batman.Cms.Core.Tools;
using Batman.Cms.Domains;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Batman.Cms.Services
{
    public class ArticleTypeAppSvc : ServiceBase<ArticleType>
    {
        public ArticleTypeAppSvc(IRepository<ArticleType> repository, ToolBox toolBox) : base(repository, toolBox)
        {
        }

        public void Create(CreateArticleTypeInput model)
        {
            var entity = ObjectMapper.Map<ArticleType>(model);

            Repository.Insert(entity);
        }

        public void Update(UpdateArticleTypeInput model)
        {
            var entity = ObjectMapper.Map<ArticleType>(model);

            Repository.Update(entity);
        }

        public List<ArticleType> GetList(ArticleTypeFilter filter)
        {
            var data = Repository.GetAll().AsNoTracking().ToList();

            return data;
        }
    }
}
